﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace SFJDNotifyIcon
{
    /// <summary>
    /// Win_Debug.xaml 的交互逻辑
    /// </summary>
    public partial class Win_Debug : Window
    {
        private RichTextBox richText = null;
        private FlowDocument richDoc = new FlowDocument();

        public Win_Debug()
        {
            InitializeComponent();
            Ini();
        }

        private void Ini()
        {
            Title = "司法鉴定助手-调试";
            richText = new RichTextBox()
            {
                IsReadOnly = true, MinWidth = 500, MinHeight = 400,
            };
            richText.TextChanged += (s, e) => { richText.ScrollToEnd(); };
            Layout_Root.Children.Add(richText);
        }

        public void OutputMsg(string str)
        {
            Dispatcher.Invoke(new Action(delegate
            {
                var p = new Paragraph(); // Paragraph 类似于 html 的 P 标签  
                var r = new Run(str); // Run 是一个 Inline 的标签
                p.Inlines.Add(r);
                p.LineHeight = 1;
                p.Foreground = Brushes.Black;//设置字体颜色  
                richDoc.Blocks.Add(p);
                richText.Document = richDoc;
                richText.Focus();
            }));
        }
    }
}
